//
//  HGQRCode.m
//  CordovaDemo
//
//  Created by xwx on 2018/8/2.
//

#import "HGQRCode.h"
#import "QRcodeViewController.h"


@implementation HGQRCode

-(void)startScan:(CDVInvokedUrlCommand *)command{
    
    
    if (command.arguments.count > 0) {
        
        QRcodeViewController *QR = [[QRcodeViewController alloc]init];
        QR.block = ^(NSString *string) {
           
            
           // CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
           CDVPluginResult *result =[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:string];
            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
            
        };
        
        [self.viewController.navigationController pushViewController:QR animated:YES];
        
    
    
    }
    else{
        //如果没有入参,则回调JS失败函数
        CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"没有入参alert title"];
        [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
    }
    
}

@end
